package Day014_Lambda表达式_Stream流.ZuoYe.Test4;

import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author zhangyan
 * @date 2020/5/5 18:40
 */
public class Test4 {
    public static void main(String[] args) {
        //数组1
        String[] arr1 = {"郭靖","杨康"};
        //数组2
        String[] arr2 = {"黄蓉","穆念慈"};

        //获取数组的Stream流
        Stream<String> stream1 = Stream.of(arr1);
        Stream<String> stream2 = Stream.of(arr2);

        //组合
        Stream<String> concat = Stream.concat(stream1, stream2);

        //收集到List集合中

        //使用Collectors工具类的toList方法得到Collector接口的实例 collector
        Collector<Object, ?, List<Object>> collector = Collectors.toList();

        //调用collect方法
        List<Object> list = concat.collect(collector);
        //打印集合
        System.out.println(list);

    }
}
